package com.neolix.watch.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.neolix.watch.R;

import org.joda.time.DateTime;

import static com.neolix.watch.util.StringUtil.formatTimeToMonthAndDayString2;
import static com.neolix.watch.util.StringUtil.getWeekInfo;

public class SportRecordItemView extends LinearLayout {

    private TextView currentDate;
    private TextView currentWeek;

    public SportRecordItemView(Context context) {
        super(context);
        initUi();
    }

    public SportRecordItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initUi();
    }

    public SportRecordItemView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        initUi();
    }

    protected void initUi() {
        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View container = inflater.inflate(R.layout.view_sport_item, this, true);

        currentWeek = (TextView) container.findViewById(R.id.current_week);
        currentDate = (TextView) container.findViewById(R.id.current_date);
    }

    public void setModel(DateTime dateTime) {
        currentWeek.setText(getWeekInfo(dateTime));
        currentDate.setText(formatTimeToMonthAndDayString2(dateTime));
    }
}
